<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model
        ref="form"
        :model="model"
        slot="detail"
        :rules="validatorRules"
        :label-col="labelCol"
        :wrapper-col="wrapperCol"
      >
        <a-form-model-item label="屏蔽劝阻" prop="operation">
          <a-radio-group name="tenantStatus" v-model="model.operation">
            <a-radio :value="1">不再劝阻</a-radio>
            <a-radio :value="2">恢复劝阻</a-radio>
          </a-radio-group>
        </a-form-model-item>
        <a-form-model-item v-if="showFlowSubmitButton">
          <a-button @click="submitForm">提 交</a-button>
        </a-form-model-item>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
import { dissuadeShield } from '@/api/warning/WarningData.js'
export default {
  name: 'ShieldDissuadetForm',
  data() {
    return {
      model: {
        operation: 1
      },
      id: '',
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        operation: [{ required: true, message: '请选择屏蔽劝阻!' }],
      },
      getSelectKeyDatas: []
    }
  },
  computed: {
    formDisabled() {
      if (this.normal === false) {
        if (this.formData.disabled === false) {
          return false
        } else {
          return true
        }
      }
      return this.disabled
    },
    disabledId() {
      return this.id ? true : false
    },
    showFlowSubmitButton() {
      if (this.normal === false) {
        if (this.formData.disabled === false) {
          return true
        } else {
          return false
        }
      } else {
        return false
      }
    },
  },
  created() {},
  methods: {
    show(record) {
      this.model = record ? Object.assign({}, record) : this.model
      this.id = record ? record.id : ''
      this.visible = true
    },
    submitForm() {
      const parameter = {
        operation: this.model.operation,
        userList: this.getSelectKeyDatas
      }
      dissuadeShield(parameter)
        .then((res) => {
          if (res.success) {
            this.$message.success(res.message)
            this.$emit('ok');
          } else {
            this.$message.warn(res.message)
          }
        })
        .catch((e) => {
          this.$message.warn('请求失败！')
        })
    }
  }
}
</script>
